<?php
namespace app\miniprogram\controller;

use think\Log;

/**
 * 支付
 */
class Pay extends Base
{
	protected $noNeedLogin = ['notify', 'pay_service_notify'];
	protected $process = 'Pay';

    public function index() {
    	$this->ajax_process(function($process, $user){
    		return $process->order($user);
    	});
    }

    public function notify(){
	    $app = loadTool('Wechat')->payment('miniprogram2');
	    $response = $this->ajax_process(function($process, $user) use ($app){
    		return $process->notify($app, loadEnum('PayType')->code2key('notify'));
    	}, null, true);
	    return $response;
    }

    public function pay_service_notify(){
	    $app = loadTool('Wechat')->payment('miniprogram_oxy');
	    $response = $this->ajax_process(function($process, $user) use ($app){
    		return $process->notify($app, loadEnum('PayType')->code2key('pay_service_notify'));
    	}, null, true);
	    return $response;
    }
}
